package top.wu2020.lazy.ws.chat.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.wu.framework.web.spring.EasyController;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import top.wu2020.lazy.ws.chat.domain.model.community.Community;
import top.wu2020.lazy.ws.chat.application.command.community.CommunityRemoveCommand;
import top.wu2020.lazy.ws.chat.application.command.community.CommunityStoryCommand;
import top.wu2020.lazy.ws.chat.application.command.community.CommunityUpdateCommand;
import top.wu2020.lazy.ws.chat.application.command.community.CommunityQueryListCommand;
import top.wu2020.lazy.ws.chat.application.command.community.CommunityQueryOneCommand;
import top.wu2020.lazy.ws.chat.application.CommunityApplication;
import top.wu2020.lazy.ws.chat.application.dto.CommunityDTO;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe community 
 *
 * @author Jia wei Wu
 * @date 2024/05/24 08:52 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "提供者")
@EasyController("/community")
public class CommunityProvider  {

    @Resource
    private CommunityApplication communityApplication;

    /**
     * describe 新增
     *
     * @param communityStoryCommand 新增     
     * @return {@link Result<Community>} 新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "新增")
    @PostMapping("/story")
    public Result<Community> story(@RequestBody CommunityStoryCommand communityStoryCommand){
        return communityApplication.story(communityStoryCommand);
    }
    /**
     * describe 批量新增
     *
     * @param communityStoryCommandList 批量新增     
     * @return {@link Result<List<Community>>} 新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "批量新增")
    @PostMapping("/batchStory")
    public Result<List<Community>> batchStory(@RequestBody List<CommunityStoryCommand> communityStoryCommandList){
        return communityApplication.batchStory(communityStoryCommandList);
    }
    /**
     * describe 更新
     *
     * @param communityUpdateCommand 更新     
     * @return {@link Result<Community>} 领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "更新")
    @PutMapping("/updateOne")
    public Result<Community> updateOne(@RequestBody CommunityUpdateCommand communityUpdateCommand){
        return communityApplication.updateOne(communityUpdateCommand);
    }
    /**
     * describe 查询单个
     *
     * @param communityQueryOneCommand 查询单个     
     * @return {@link Result<CommunityDTO>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询单个")
    @GetMapping("/findOne")
    public Result<CommunityDTO> findOne(@ModelAttribute CommunityQueryOneCommand communityQueryOneCommand){
        return communityApplication.findOne(communityQueryOneCommand);
    }
    /**
     * describe 查询多个
     *
     * @param communityQueryListCommand 查询多个     
     * @return {@link Result<List<CommunityDTO>>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询多个")
    @GetMapping("/findList")
    public Result<List<CommunityDTO>> findList(@ModelAttribute CommunityQueryListCommand communityQueryListCommand){
        return communityApplication.findList(communityQueryListCommand);
    }
    /**
     * describe 分页查询多个
     *
     * @param communityQueryListCommand 分页查询多个     
     * @return {@link Result<LazyPage<CommunityDTO>>} 分页DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "分页查询多个")
    @GetMapping("/findPage")
    public Result<LazyPage<CommunityDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute CommunityQueryListCommand communityQueryListCommand){
        return communityApplication.findPage(size,current,communityQueryListCommand);
    }
    /**
     * describe 删除
     *
     * @param communityRemoveCommand 删除     
     * @return {@link Result<Community>}      
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "删除")
    @DeleteMapping("/remove")
    public Result<Community> remove(@ModelAttribute CommunityRemoveCommand communityRemoveCommand){
        return communityApplication.remove(communityRemoveCommand);
    }
}